<?php
/**
 * Created by PhpStorm.
 * User: hooshim
 * Date: 2014-12-03
 * Time: 오전 11:23
 */

header("Content-Type:text/html;charset=utf-8");
header("Cache-Control:no-cache");
header("Pragma:no-cache");

include_once ($_SERVER['DOCUMENT_ROOT']."/inc/conn.inc.php");
include_once ($_SERVER['DOCUMENT_ROOT']."/inc/function.inc.php"); ##property 파일 인크루드됨.

    //## 파라미터 선언
    $billCd 			= $_POST['billCd'];
    //if (!$expressCd) $expressCd = 'EMS';

    // Table 이름 선언
    $tbname = "tblExpress";

    $curDt =date("Y-m-d");

    $query = "SELECT billCd, issueDt, A.expressCd, cargoType, expressClass, destNationCd, destAddr, destZone, B.zoneNm, compCd, consignee, item, cargoTon ";
    $query .= ", REPLACE(CONVERT(varchar, CAST(A.weightTon AS money), 1), '.00', '') weightTon, REPLACE(CONVERT(varchar, CAST(A.ratePerWeight AS money), 1), '.00', '') ratePerWeight ";
    $query .= ", REPLACE(CONVERT(varchar, CAST(A.totalRate AS money), 1), '.00', '') totalRate, REPLACE(CONVERT(varchar, CAST(A.totalRatePerWeight AS money), 1), '.00', '') totalRatePerWeight ";
    $query .= ", REPLACE(CONVERT(varchar, CAST(A.compDCRate AS money), 1), '.00', '') compDCRate, REPLACE(CONVERT(varchar, CAST(A.compDCAmount AS money), 1), '.00', '') compDCAmount ";
    $query .= ", REPLACE(CONVERT(varchar, CAST(A.compOilRate AS money), 1), '.00', '') compOilRate, REPLACE(CONVERT(varchar, CAST(A.compOilAmount AS money), 1), '.00', '') compOilAmount ";
    $query .= ", REPLACE(CONVERT(varchar, CAST(A.compInvAmount AS money), 1), '.00', '') compInvAmount, REPLACE(CONVERT(varchar, CAST(A.compTotalInvAmount AS money), 1), '.00', '') compTotalInvAmount ";
    $query .= ", REPLACE(CONVERT(varchar, CAST(A.compExtraCharge AS money), 1), '.00', '') compExtraCharge, REPLACE(CONVERT(varchar, CAST(A.carrDCRate AS money), 1), '.00', '') carrDCRate ";
    $query .= ", REPLACE(CONVERT(varchar, CAST(A.carrDCAmount AS money), 1), '.00', '') carrDCAmount, REPLACE(CONVERT(varchar, CAST(A.carrOilRate AS money), 1), '.00', '') carrOilRate ";
    $query .= ", REPLACE(CONVERT(varchar, CAST(A.carrOilAmount AS money), 1), '.00', '') carrOilAmount, REPLACE(CONVERT(varchar, CAST(A.carrInvAmount AS money), 1), '.00', '') carrInvAmount ";
    $query .= ", REPLACE(CONVERT(varchar, CAST(A.carrTotalInvAmount AS money), 1), '.00', '') carrTotalInvAmount, REPLACE(CONVERT(varchar, CAST(A.extraCharge AS money), 1), '.00', '') extraCharge ";
    $query .= ", REPLACE(CONVERT(varchar, CAST(A.profit AS money), 1), '.00', '') profit ";
    $query .= ", remarks, A.flag ";
    $query .= " FROM {$tbname} A LEFT JOIN tblZoneCd B ON A.destZone=B.zoneCd AND A.expressCd=B.expressCd ";
    $query .= " WHERE billCd='{$billCd}'";
    $logger->debug($query ."<br>[#FROM:" . $G_remote_ip."#]"); ## 쿼리 로그 작성
    $result = makeJSONArray($query, $tbname);

    $output = json_encode($result);
    $output = urldecode($output);
    echo iconvDecode($output);
    $logger->debug($output ."<br>[#FROM:" . $G_remote_ip."#]"); ## 결과 로그 작성
?>